package lelouet.sh3d.plugins.sweetDatacenter;

import java.io.File;

import javax.swing.JFileChooser;

import com.eteks.sweethome3d.plugin.PluginAction;

public class LoadEntropyButton extends PluginAction {

	JFileChooser fc;

	SweetDatacenterPlugin parent = null;
	{
		fc = new JFileChooser();
		fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
	}

	public LoadEntropyButton(final SweetDatacenterPlugin parent) {
		super("lelouet.sh3d.plugins.sweetDatacenter.ApplicationPlugin",
				"LOAD_SERVERS_ENTROPY", parent.getPluginClassLoader(), true);
		this.parent = parent;
	}

	@Override
	public void execute() {
		final int returnVal = fc.showOpenDialog(null);
		if (returnVal == JFileChooser.APPROVE_OPTION) {
			final File file = fc.getSelectedFile();
			System.out.println("loading entropy file " + file);
			parent.getGEFactory().parseEntropy(file);
		}
	}

}
